load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@rules_cc//cc:defs.bzl", "cc_library")

package(default_visibility = ["//visibility:public"])

string_flag(
    name = "quadmath",
    build_setting_default = "off",
    values = [
        "off",
        "on",
    ],
    visibility = ["//visibility:public"],
)

config_setting(
    name = "off",
    flag_values = {":quadmath": "off"},
)

config_setting(
    name = "on",
    flag_values = {":quadmath": "on"},
)

cc_library(
    name = "boost.charconv",
    srcs = glob(["src/*.cpp"]),
    hdrs = glob([
        "include/**/*.*pp",
        "src/*.*pp",
    ]),
    defines = ["BOOST_ALL_NO_LIB"] + select({
        ":on": ["BOOST_CHARCONV_HAS_QUADMATH"],
        ":off": ["BOOST_CHARCONV_NO_QUADMATH"],
    }),
    features = ["parse_headers"],
    includes = ["include"],
    deps = [
        "@boost.assert",
        "@boost.config",
        "@boost.core",
    ],
)
